<?php

/**
 * ClassName:用户聊天列表操作对象
 * @auditor LeiJunXiang
 * @time 2024/12/03
 */

namespace app\modelOpreate\onlineChat;

use app\modelOpreate\ModelOpeBase;
use think\facade\Db;

class ChatListOpe extends ModelOpeBase
{
    const TOOL_CHAT_LIST_OPE = "ChatListOpe";
    /**
     * 保存列表
     * @return void
     */
    public function saveList($arr)
    {
        $db = Db::table($this->table);
        $flag = $db->insert($arr);
        return $flag;
    }

    /**
     * 获取房间号(关联用户id,排序更换用户id)
     */
    public function getRoomNumber($relationshipUserId,$sortToUserId)
    {
        $roomNumber = Db::table($this->table)
            ->where('relationshipUserId', $relationshipUserId)
            ->whereOr('relationshipUserId', $sortToUserId)
            ->field('roomNumber')
            ->find('roomNumber');
        return $roomNumber['roomNumber'];
    }

}